import pandas as pd

data1 = {
    "Name": ["Alice", "Bob", "Tom"],
    "Age": [22, 23, 24],
    "City": ["Beijing", "Shanghai", "Guangzhou"],
}
df1 = pd.DataFrame(data1)


data2 = {
    "Name": ["Lisai", "Malike", "Lusai"],
    "Age": [11, 12, 13],
    "City": ["Guiyang", "Chengdu", "Wuhan"],
}
df2 = pd.DataFrame(data2)

# 1.相同的列, 数据拼接concat
df3 = pd.concat([df1, df2], ignore_index=True)
print(df3)
""" 
     Name  Age       City
0   Alice   22    Beijing
1     Bob   23   Shanghai
2     Tom   24  Guangzhou
3   Lisai   11    Guiyang
4  Malike   12    Chengdu
5   Lusai   13      Wuhan
"""

# 2.横向合并（按列合并）
df4 = pd.concat([df1, df2], axis=1)
print(df4)
""" 
    Name  Age       City    Name  Age     City
0  Alice   22    Beijing   Lisai   11  Guiyang
1    Bob   23   Shanghai  Malike   12  Chengdu
2    Tom   24  Guangzhou   Lusai   13    Wuhan
"""
